package com.sun;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegularFind {
    public static void main(String[] args) {
        String s = "the quick brown fox jumps over the lazy dog";
//        Pattern pattern =  Pattern.compile("\\w+");//提取每一个单词
//        Pattern pattern =  Pattern.compile("the");//提取the
        Pattern pattern =  Pattern.compile("\\w*o\\w*");//提取带o的单词
        Matcher matcher = pattern.matcher(s);
        while (matcher.find()){
            System.out.println(matcher.start()+" "+matcher.end());
            System.out.println(s.substring(matcher.start(),matcher.end()));
        }


    }
}
